<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'=>'required|min:2|max:30',
            'email'=>['required','email','unique:users'],
            'password'=>'required|min:6|confirmed'
        ];
    }
    public function messages(){
        return [
            'name.required'=>'用户姓名不能为空，必须填写',
            'name.min'=>'用户姓名至少:min个字符',
            'name.max'=>'用户姓名不得多于:max个字符',
            'email.required'=>'email不能为空，必须填写',
            'email.email'=>'email格式不正确',
            'email.unique'=>'email已经存在，不能重复',
            'password.required'=>'密码不能为空，必须填写',
            'password.min'=>'密码至少包括:min个字符',
            'password.confirmed'=>'两次输入密码不一致',
        ];
    }
}
